-
-
Notifications
You must be signed in to change notification settings - Fork 602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[16.0][ADD] pos_partner_location_map #1002
[16.0][ADD] pos_partner_location_map #1002
Conversation
084c41c
to
70eae27
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the name of the module should contain "google".
}).then((response) => { | ||
loadJS( | ||
"https://maps.googleapis.com/maps/api/js?key=" + | ||
response + | ||
"&libraries=places" | ||
); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to add check here if resonse is not falsy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
@@ -0,0 +1,2 @@ | |||
This module allows to select partner address directly on map. | |||
For this Google Maps are used. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this module heavily depends on google, it should be renamed to something like pos_partner_location_map_google
. Because there are other services like google maps. For example yandex maps. https://yandex.ru/dev/maps/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this module heavily depends on google, it should be renamed to something like
pos_partner_location_map_google
. Because there are other services like google maps. For example yandex maps. https://yandex.ru/dev/maps/
I think the name of the module should contain "google".
Hi @em230418 @legalsylvain thank you for the feedback! This module implements core behaviour for any map provide. Google Is just the first one on the list. This is why we have opted for such a name keeping OpenStreetMap as a "Roadmap/Todo" item So anyone could modify this module later without a need of creating a separate one for each map provider.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This module implements core behaviour for any map provide. Google Is just the first one on the list.
Do you plan to maintain behaviour of every map provider that is included to this module by others (1) or just google and OSM only (2)? If (2), you need to create seperate modules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This module implements core behaviour for any map provide. Google Is just the first one on the list.
Do you plan to maintain behaviour of every map provider that is included to this module by others (1) or just google and OSM only (2)? If (2), you need to create seperate modules.
Yes, this module is designed to be extendable with other map providers as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, my question was incorrect.
So anyone could modify this module later without a need of creating a separate one for each map provider.
Do you plan to maintain behaviour of every map provider that WILL BE included to this module (pos_partner_location_map) by others (1) or just google and OSM only (2)? If (2), you need to create separate modules.
Yes, this module is designed to be extendable with other map providers as well
I don't have any doubt on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, my question was incorrect.
So anyone could modify this module later without a need of creating a separate one for each map provider.
Do you plan to maintain behaviour of every map provider that WILL BE included to this module (pos_partner_location_map) by others (1) or just google and OSM only (2)? If (2), you need to create separate modules.
Yes, this module is designed to be extendable with other map providers as well
I don't have any doubt on this.
Yes if someone will open a PR with new map providers we will merge it when reviewed and approved.
"name": "Point of Sale - Customer Screen", | ||
"version": "16.0.1.0.0", | ||
"category": "Point Of Sale", | ||
"summary": "Point of Sale - Customers can easily interact with point of sale", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Show and set partner location directly on map in POS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
@@ -0,0 +1,22 @@ | |||
{ | |||
"name": "Point of Sale - Customer Screen", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
POS Partner Location Map
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
class ResPartner(models.Model): | ||
_inherit = "res.partner" | ||
|
||
map_partner_address = fields.Char() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This field might be misleading for a user. Because there are core Odoo fields used for the same goal.
We should parse this string into Odoo address fields instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also noting, that there is OCA module for google map integration. https://github.com/OCA/geospatial/tree/14.0/web_view_google_map
Yup we are aware of. However this one is based on the Odoo core module base_geolocalize for better compatibility |
@isserver1, @legalsylvain, @em230418 Could you make code review please? |
Not totally agree with that point. I think that if openstreetmap is in the roadmap, many modules should exists :
The module you provide is quite complex. (that is normal). So if tomorrow openstreetmap is implemented in the same module, we'll have a lot of useless code installed, that is not a good idea. (javascript asset related to google, or file like this address_google_struct.py). For maintenability reason also. If we implement osm in the same module as google, and a contributor want to migrate the module in version 17, the current design will ask to the contributor to migrate both features, even if one of the feature is not desired by the contributors. At this step, I see two possibilities : What do you think ? |
I think that we can split the module into two separate ones |
In general, in the OCA, it's recommended to separate PRs. however, in this case, module A doesn't make sense without module B, and vice versa. so i don't see any advantage in separating, you can do the refactor in the same branch. That will be easier. Thanks a lot! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not testes. code LGTM, please squash commit by modules
163f3c6
to
0605606
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functional ok
hey @legalsylvain @em230418 could you please check again? Would be great to have it merged |
@legalsylvain @em230418 I'm really sorry for bothering just didn't want to get it stalled |
Sorry for the delay. I can take a look on runboat, but there is no link. Could you rebase, to relaunch the CI ? |
0605606
to
1a44739
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General review : No functional review finally, I have no Google API key. So feature doesn't work on runboat.
Nitpicking + non blocking :
The lat / long are not well displayed in small screen. other fields added after will be maybe not well displayed. Maybe better to follow the classic rules "one field per line".
Nothing to do with your PR :
on runboat, I can not change data on partner form view (in PoS) and save. (changes are discarded).
Don't know why, but the bug is present also in runboat of 16.0 branch. so unrelated with your contribution. (but annoying !)
class ResConfigSettings(models.TransientModel): | ||
_inherit = "res.config.settings" | ||
|
||
auto_create_map_data = fields.Boolean( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question :
This fields looks to be not used (and not available in any view).
Did I missed something ?
class PosConfig(models.Model): | ||
_inherit = "pos.config" | ||
|
||
geolocalize_tech_name = fields.Char(compute="_compute_geolocalize") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand this field correctly, this should be a Selection field, don't you think ? (openstreetmap / googlemap). don't you think ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand this field correctly, this should be a Selection field, don't you think ? (openstreetmap / googlemap). don't you think ?
I thinks it's not better idea. This field is compute by Geo Provider
configuration parameter. Provider we can update or add new what raise an error, that is why this field is just Char.
@api.model | ||
def _set_extended_data(self): | ||
return {} | ||
|
||
def _set_pos_config_parameter(self, tech_name, ext_vals=None): | ||
_ = ext_vals or {} | ||
for config in self: | ||
config.geolocalize_tech_name = tech_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand very well why both functions are required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand very well why both functions are required.
These functions helping fast and without problems configure new providers for POS.
_inherit = "pos.session" | ||
|
||
def _loader_params_res_partner(self): | ||
res = super(PosSession, self)._loader_params_res_partner() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpicking.
res = super(PosSession, self)._loader_params_res_partner() | |
res = super()._loader_params_res_partner() |
) { | ||
return true; | ||
} | ||
return super.accessToMap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function call must be returned, not function itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function call must be returned, not function itself.
This function is a property, that is why super.accessToMap
returned property value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see.
} | ||
|
||
onHandleMap() { | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returned value is not used. No need to return anything.
this.geocoder.geocode({location: latLng}, (results, status) => { | ||
if (status === google.maps.GeocoderStatus.OK) { | ||
this.getFormattedAddress(results[0].place_id); | ||
this.addrInput.el.value = results[0].formatted_address; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- geocode returns formatted address in results[0].formatted_address and here we also do something to get formatted address using "getFormattedAddress".
- this.address inside body getFormattedAddress could be set in 5 seconds if bad internet connection, meanwhile this.addrInput.el.value is set very quickly. Is it fine here? You are sure, we don't need to "await" for getFormattedAddress?
update_marker(lat, lng) { | ||
super.update_marker(lat, lng); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use "camelCase", not "snake_case". Since in js snake_case naming for methods is not popular.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I will change it.
status = google.query_addr({"place_id": place_id}) | ||
return google.get_result() if status else {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On bad status, there should be warning indicated. At least in logs.
@legalsylvain @em230418 Could you check changes? |
039569b
to
1601e38
Compare
@@ -0,0 +1 @@ | |||
This module is base for module pos_partner_location_google_map (Google Map). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This module implements base functionality for using different map providers in POS.
It allows to select partner location directly on a map and stores selected location in the res.partner model.
It also tries to evaluate partner's address from coordinates and provides a helper function that generates location QR code.
NB: This is a core module which is meant to be used in further customisations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description is updated
|
||
def _compute_qr_code_url(self): | ||
"""Compute QR Code URL for map provider""" | ||
self.write({"qr_code_url": ""}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a non stored field. So using "write" will do no benefit here because no db tables are updated.
You should use "update" instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with you, applied proposed changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add author and license information to all files.
Everything else looks good
d7368bb
to
6f28089
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally LGTM
@em230418, could you update your review ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
1dab65c
to
37c54c5
Compare
Hey @em230418 happy new year! Waiting for your updated review 😄 |
if (this.accessToMap) { | ||
await this.partnerMap(); | ||
} else { | ||
this.showPopup("ErrorPopup", { | ||
title: this.env._t("Map Error"), | ||
body: this.env._t("Cannot access map functions!"), | ||
}); | ||
} | ||
} catch (e) { | ||
if ( | ||
identifyError(e) instanceof ConnectionLostError || | ||
ConnectionAbortedError | ||
) { | ||
this.showPopup("OfflineErrorPopup", { | ||
title: this.env._t("Network Error"), | ||
body: this.env._t( | ||
"Cannot access product information screen if offline." | ||
), | ||
}); | ||
} else { | ||
this.showPopup("ErrorPopup", { | ||
title: this.env._t("Unknown error"), | ||
body: this.env._t( | ||
"An unknown error prevents us from loading product information." | ||
), | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we "await" from partnerMap, I suggest also to await "this.showPopup".
def setUp(self): | ||
super(TestPointOfSaleCommon, self).setUp() | ||
|
||
def test_loader_params_res_partner(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to override setUp here?
partner = self.env["res.partner"].search([("id", "=", partner.id)]) | ||
self.assertEqual(partner.partner_latitude, 15.0) | ||
self.assertFalse(partner.partner_longitude) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why running "search" instead of validating fields?
@em230418 Could you check changes? |
18d3684
to
0cbc999
Compare
Hi @legalsylvain , would appreciate you having a look at this when you have time. Thank you in advance!) |
I can not test on runboat. But there are many approvals, so : /ocabot merge nobump |
Hey, thanks for contributing! Proceeding to merge this for you. |
Congratulations, your PR was merged at ae161b8. Thanks a lot for contributing to OCA. ❤️ |
This module allows to select partner address directly on map. For this Google Maps are used.